package ec.edu.cec.java.adv.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * * Clase utilitaria para el manejo de la conexion *
 * 
 * @author Pablo *
 */

public class ConnectionManager {
	private static Connection connection = null;
	private static String USR = "root";
	private static String PSWD = "abc123";
	private static String URL = "jdbc:mysql://127.0.0.1:3306/sakila";

	public static Connection getConnection() {
		if (connection == null) {
			try {
				connection = DriverManager.getConnection(URL, USR, PSWD);
				System.out.println("conexion exitosa");
			} catch (SQLException e) {
				System.out.println("Problemas al obtener la coneccion");
				e.printStackTrace();
			}
		}
		return connection;
	}

	public static void main(String[] args) {
		System.out.println("prueba de conexion");
		getConnection();
	}
}